﻿@model List<Sharp.WebBooter.Areas.CMS.Models.SubscriberSettingViewModel>
<style>
    .SubscriberItem {
        display: block;
        width: 120px;
        float: left;margin-left:30px;
    }
</style>
<div class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span></button>
                <h4 class="modal-title">订阅项配置</h4>
            </div>
            <div class="modal-body" id="modalcontent">
                @using (Html.Bootstrap().BeginForm(c => c.Horizontal()))
                {
                    <div class="form-group" id="SubscriberItems">
                        @foreach (var item in Model)
                        {
                            <label class="checkbox m-l-12 m-t-none m-b-none i-checks SubscriberItem"><input type="checkbox" value="@item.Id" @item.Checked name="SubscriberIds"><i></i>@item.Title</label>
                        }
                    </div>
                }
            </div>
            <div class="modal-footer">
                @Html.Bootstrap().Button("保存").Style(BootstrapStyle.Primary).Click("SaveConfig();")
                @Html.Bootstrap().Button("关闭").Style(BootstrapStyle.Default).Attribute("data-dismiss", "modal")
            </div>
        </div>
    </div>
</div>
<script>
    SaveConfig = function () {
        $.ajax({
            type: "POST",
            url: "@Url.Action("SaveSubscriber")",
            data: $("#modalcontent input").serialize(),
            dataType: "json",
            success: function (data) {
                if (data.errors.length > 0) {
                    swal("出错啦！", data.errors, "error");
                }
                else {
                    window.app.modalClose();
                }
            }
        });
    }
    $(function() {
        $('#SubscriberItems').sortable();
    });
</script>